package com.deer.backup;

import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;

import com.deer.backup.utils.JavaFxSystemTray;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.web.WebView;
import javafx.stage.Stage;


/**
 * @description 描述信息
 * @author deer
 * @date 2023-06-14 15:29:54
 */
public class JavaFxAppStart extends Application {

	public static void main(String[] args) {
		launch();
	}

	@Override
	public void start(Stage stage) throws Exception {
		stage.setTitle("服务器备份小程序");
		// 访问内置网页
		WebView webView = new WebView();

		webView.getEngine().load("http://127.0.0.1:8081/backup/main");
		// 设置默认字体
		ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
		// 设置图标
		stage.getIcons().add(new Image(resourcePatternResolver.getResource("/static/deer.png").getInputStream()));

		Scene scene = new Scene(webView, 950, 580);
		stage.setScene(scene);
		stage.show();
		// 创建系统托盘，监听头部关闭，缩小到系统托盘中
		JavaFxSystemTray instance = JavaFxSystemTray.getInstance();
		instance.listen(stage);
	}

}
